function SelectTag(t) {
	this.child = t.child || ".sx_child",this.url=t.url, this.over = t.over || "on", this.all = t.all || ".all", this.init()
}
$.extend(SelectTag.prototype, {
	init: function() {
		var t = this;
		t._bindEvent()
	},
	_bindEvent: function() {
		var t = this;
		$(t.child).click(function(e) {
			e.preventDefault();
			var i = t.url,
				r = $(this).attr("rel"),
				n = $(this).attr("name");
//			alert(n);
			if(!$(this).hasClass(t.over)){
				//清除此条目下的所有选中状态
				$("[name=" + n + "]").removeClass(t.over)
				
				//将现在的条件置为选中状态
				$(this).addClass(t.over);
				
				
				//取出所有选中状态的条件
				var p='?';
				$(".on").each(function() {
					let rel=$(this).attr("rel");
					let name=$(this).attr("name");
//					console.log(name+":"+rel);
					if(rel==''||rel==null){
						//不处理
					}else{
						p+=name+'='+rel+'&';
					}
				})
				console.log(p);
				
				$.ajax({
					url:t.url+p,
					type:"get",
					success:function(result){
						$(".case").children().remove();
						for(var i=0;i<result.rows.length;i++){
		                    var title=result.rows[i].hname;
		                    var id=result.rows[i].id;
		                    var source=result.rows[i].haddress;
		                    var servicetime=result.rows[i].servicetime;
		                    var advantage=result.rows[i].advantage;
		                    var introduction=result.rows[i].introduction;
		                    var html=`<li>
		                    <div class="case_1">
		                        <h1 style="font-size: 25px;font-family: inherit;font-weight: 500;line-height: 1.1;color: inherit;">
		                        <a style="text-decoration : none;color: #428bca;" href="actJoin.html?id=${id}">${title}</a>
		                        </h1>
		                        <span style="font-size: 16px;">地址：${source}</span>
		                    	<span style="font-size: 16px;">服务时间：${servicetime}</span>
		                        <span style="font-size: 16px;">特色：${advantage}</span>
		                        <span style="font-size: 16px;">简介：${introduction}</span>
		                    </div></li>`;
		                    
		                    $(".case").append(html);
		                }
					}
				})
			}
		}), $(t.all).click(function(e) {
//			e.preventDefault();
//			var i = window.location.href,
//				n = $(this).attr("name");
//			$("[name=" + n + "]").removeClass(t.over), $(this).addClass(t.over), window.location.href = t._delUrlPar(i, n)
		})
	},
	_delUrlPar: function(t, e) {
		var n = "";
		if(t.indexOf("?") == -1) return t;
		n = t.substr(t.indexOf("?") + 1);
		var r = "",
			a = "";
		if(n.indexOf("&") != -1) {
			r = n.split("&");
			for(i in r) r[i].split("=")[0] != e && (a = a + r[i].split("=")[0] + "=" + r[i].split("=")[1] + "&");
			return t.substr(0, t.indexOf("?")) + "?" + a.substr(0, a.length - 1)
		}
		return r = n.split("="), r[0] == e ? t.substr(0, t.indexOf("?")) : t
	},
	_changeURLPar: function(t, e, i) {
		var n = this,
			r = e + "=([^&]*)",
			a = e + "=" + i,
			s = encodeURI(n._getQueryString(e));
		return t.match(r) ? t = t.replace(s, i) : t.match("[?]") ? t + "&" + a : t + "?" + a
	},
	_getQueryString: function(t) {
		var e = new RegExp("(^|&)" + t + "=([^&]*)(&|$)", "i"),
			i = window.location.search.substr(1).match(e);
		return null != i ? decodeURI(i[2]) : null
	},
	_select: function() {
		var t = this,
			e = window.location.href;
		$(t.child).each(function() {
//			var i = $(this).attr("name") + "=" + $(this).attr("rel"),
//				n = new RegExp(encodeURI(i), "g");
//			if(n.test(e)) {
//				$(this).addClass(t.over);
//				var r = $(this).attr("name");
//				$("[name=" + r + "]").eq(0).removeClass(t.over)
//			} else $(this).removeClass(t.over)
			//$(this).addClass(t.over);
		})
	}
});